package com.example.wxamapnav;

import android.widget.Toast;

import android.content.Context;

import com.alibaba.weex.plugin.annotation.WeexModule;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.Poi;
import com.amap.api.navi.AmapNaviPage;
import com.amap.api.navi.AmapNaviParams;
import com.amap.api.navi.AmapNaviType;
import com.amap.api.navi.AmapPageType;
import com.taobao.weex.WXEnvironment;
import com.taobao.weex.annotation.JSMethod;
import com.taobao.weex.common.WXModule;

/**
 * Created by renwenqiang on 2019/5/13.
 */
@WeexModule(name = "wxamapnav", lazyLoad = true)
public class WXAmapNav extends WXModule {

    @JSMethod(uiThread = true)
    public void navtols(Float endLat, Float endLng) {
//        Toast.makeText(mWXSDKInstance.getContext(), "Hello Eros test Plugin", Toast.LENGTH_LONG).show();
//        AmapNaviPage.getInstance().showRouteActivity(context, new AmapNaviParams(null), IndexActivity.this);
//        Poi start = new Poi("三元桥", new LatLng(39.96087,116.45798), "");
//        Poi start = new Poi("三元桥", new LatLng(startLat,startLng), "");
/**终点传入的是北京站坐标,但是POI的ID "B000A83M61"对应的是北京西站，所以实际算路以北京西站作为终点**/
/**Poi支持传入经纬度和PoiID，PoiiD优先级更高，使用Poiid算路，导航终点会更合理**/
//        Poi end = new Poi("北京站", new LatLng(39.904556, 116.427231), "B000A83M61");
        Poi end = new Poi(null, new LatLng(endLat, endLng), null);
        AmapNaviPage.getInstance().showRouteActivity(WXEnvironment.getApplication().getApplicationContext(), new AmapNaviParams(null, null, end, AmapNaviType.DRIVER, AmapPageType.NAVI), null);
    }

}
